import {v4} from 'uuid'

//农品简介配置
export const commodityDialogChangeConfig = {
  table: 'commodity',
  title: '农品',
  formSlotNames: ['catagory'],
  formConfig: [
    {
      label: '名称',
      prop: 'name'
    },
    {
      label: '描述',
      prop: 'description'
    },
    {
      label: '单位',
      prop: 'unit'
    },
    {
      label: '价格',
      prop: 'price',
      type: 'number'
    },
    {
      label: '库存',
      prop: 'count',
      type: 'number',
      itemConfig: {
        numberConfig: {
          min: 0,
          precision: 0
        }
      }
    },
    {
      label: '分类',
      prop: 'catagory_id',
      type: 'custom',
      slotName: 'catagory',
    },
    {
      label: '状态',
      prop: 'status',
      type: 'switch'
    },
    {
      label: '展示图片',
      prop: 'img_src',
      type: 'upload'
    }
  ]
}

//农品详情配置
export const commodityDetailChangeConfig = {
  table: 'commodity_detail',
  title: '农品详情',
  afterConfig: {
    addAfterFetchData: false,
    editAfterFetchData: false
  },
  formConfig: [
    {
      label: '溯源视频',
      prop: 'source_src',
      type: 'array',
      itemConfig: {
        arrayType: 'upload',
        arrayLimit: 1,
        mediaType: 'video',
      }
    },
    {
      label: '详情图片',
      prop: 'detail_src',
      type: 'array',
      itemConfig: {
        arrayType: 'upload'
      }
    },
    {
      label: '服务',
      prop: 'service',
      type: 'form',
      itemConfig: {
        formConfig: [
          {
            label: '配送服务',
            prop: 'delivery'
          },
          {
            label: '优惠活动',
            prop: 'discounts'
          },
          {
            label: '售后服务',
            prop: 'service'
          }
        ]
      }
    },
    {
      label: '规格',
      prop: 'specification',
      type: 'form',
      itemConfig: {
        formConfig: [
          {
            label: '农户名称',
            prop: 'farmer'
          },
          {
            label: '单品规格',
            prop: 'parameters'
          },
          {
            label: '保质期限',
            prop: 'shelf_date'
          },
          {
            label: '储存方式',
            prop: 'storage'
          }
        ]
      }
    },
    {
      label: '选购规格',
      prop: 'specification_prices',
      type: 'array',
      itemConfig: {
        arrayType: 'form',
        defaultItemValue: {
          key: v4(),
          price: 1,
          weight: ''
        },
        formConfig: [
          {
            label: '价格',
            prop: 'price',
            type: 'number'
          },
          {
            label: '重量',
            prop: 'weight'
          }
        ]
      }
    }
  ]
}
